﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Web.Core;
using Web.Core.Objects;

public partial class include_product : System.Web.UI.UserControl
{
    public Product produc;
    protected void Page_Load(object sender, EventArgs e)
    {
        //Product pro = new Product();
        produc = Products.GetProductByID((int)Session["Language"], int.Parse(Request.Params["id"]));
       // ArrayList arr = new ArrayList();
       // arr.Add(pro);
        //this.img_product.ImageUrl = "../images/products/" + pro.Image;
       // this.detail.DataSource = arr;
       // this.detail.DataBind();

    }

    public string getBreadcrum(int id)
    {
        
        ArrayList bre = new ArrayList();
        Product pro = new Product();
        pro = Products.GetProductByID((int)Session["Language"], id);
        //bre.Add(pro.Name);
        int parent = pro.CategoryID;
        while (parent != 0)
        {
            DictionaryEntry dic = new DictionaryEntry();
            Category cat = new Category();
            cat = Categories.GetCategoryByID(parent, (int)Session["Language"]);
            dic.Key = cat.Id;
            dic.Value = cat.Name;
            bre.Add(dic);
            parent = cat.Parent;
        }

        string str = "";
        str += "<div class='pathway'>";
        for (int i = (bre.Count -1); i >= 0; i--)
        {
            DictionaryEntry item = (DictionaryEntry) bre[i];
            str += "<a href='?act=category&catid=" + item.Key + "' class='pathway'>" + item.Value + "</a>";
            str += "<img border='0' alt='arrow' src='images/arrow.png'>";
        }
        str += "<span>"+pro.Name+"<span></div>";

        return str;
    }
    public string getProductSameCat(int catID)
    {
        ArrayList list = new ArrayList();
        list = Products.GetAllProductsByCategoryIDVisible((int)Session["Language"], catID,1,10);
        string str = "";
        foreach (Product item in list)
        {
            str +="<div class='vmProductSnapshotContainer'>";
            str +="<span style='font-weight:bold;'>"+item.Name+"</span>";
            str +="<div class='vmProductSnapshot'>";
            str +=string.Format("<a href='?act=product&id={0}' title='{1}'><img border='0' width='170' height='216' alt='{1}' src='images/products/{2}'></a>",item.ProductID,item.Name,item.Image);
            str +="</div><span class='productPrice'>$"+item.Price+"</span><br></div>";                                                                      
        }
        return str;
    }
}
